from j264.tools.attributes.Attribute import Attribute


class DimensionAttribute(Attribute):

    ### PUBLIC METHODS ###

    def get_input_massage(self):
        def massage(self, arg):
            return tuple([float(x) for x in arg])
        return massage

    def get_input_predicate(self):
        def predicate(self, arg):
            if isinstance(arg, (list, tuple)):
                if len(arg) == 4:
                    if all([isinstance(x, (int, float)) for x in arg]):
                        if 0 < arg[2] and 0 < arg[3]:
                            return True
            return False
        return predicate

